/*
--------------------------------------------------------------------------------
				Ak-Lib. 
			 Project       	: Ak-Lib
			 Group         	: Ak-Lib R&D Team
			 Author        	: Ocean.Wang
			 Create Date 	: 05-01-2010
--------------------------------------------------------------------------------
Code Name 	:  A.K 	~v~
Description	:  Yet Another Cross-Platform Lib.
Cautions    	:
--------------------------------------------------------------------------------
Change History:
Version		: 0.1
Building 		: 05/01/10
10-05.01 first draft, build, debug and test.
--------------------------------------------------------------------------------
*/

#include "ak_cli.h"
#include "ak_appl.h"

#define MODID_TEST 		0X80


static 	int 	_Test_Dump(void * pCbArg, int vCbArg, char * pBuf, int lBuf, char * param)
{
	/* Parse the param */
	int 	len;
	char * 	aParam[S_APP_MAX_PARAM];
	SStrJ_Param(param, aParam);

	len  = 0;
	len += SYS_SNPRINTF(pBuf+len, lBuf - len, "[Test Dump Something]\n");
	return len;
}

static 	int 	_Test_Log(void * pCbArg, int vCbArg, char * pBuf, int lBuf, char * param)
{
	/* Parse the param */
	int len;

	len  = 0;
	len += SYS_SNPRINTF(pBuf+len, lBuf - len, "[Test Log Something]\n");
	return len;
}

static 	int 	_Test_CmdReg(void * pCbArg, int vCbArg, void * pModule)
{
	_t_cliCmdReg 	cmdReg;
	int 				ret;
	
	sprintf(cmdReg.cmd, "dump");
	_CBENTRY_INIT(&(cmdReg.func), _Test_Dump, NULL, 0);
	ret = SAgtApp_ModRegCmd(pModule, &cmdReg);

	sprintf(cmdReg.cmd, "log");
	_CBENTRY_INIT(&(cmdReg.func), _Test_Log, NULL, 0);
	ret = SAgtApp_ModRegCmd(pModule, &cmdReg);

	return ret;
}


static 	int 	_Test_Init(void)
{
	return 0;
}

static 	_t_appModReg 	vModReg_Test={
	/* Mod Id */
	MODID_TEST,

	/* Mod Str */
	"Test",
	
	/* 1. Module Load & Init */
	{(int (*)())_Test_Init, NULL, 0},
	{NULL, NULL, 0},
	
	/* 2. Module Status */
	{NULL, NULL, 0},
	
	/* 3. HeartBeat */
	{NULL, NULL, 0},
	
	/* 4. Fault Tolerant */
	{NULL, NULL, 0},

	/* 5. CLI */
	{(int (*)())_Test_CmdReg, NULL, 0}
};


static 	_t_appModReg *	vModReg_TestA[]={
	&vModReg_Test
};

int 	main(void)
{
	SAgtApp_Init("CliTest");
	SAgtApp_ModRegA(vModReg_TestA, _N_ARRAY(vModReg_TestA));
	SAgtApp_Exec(NULL);
	return 0;
}



